import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

export enum GoodsType {
  MEDICINE = 1, // 药品
  EQUIPMENT = 2, // 装备
  MATERIAL = 3, // 材料
  CONSUMABLE = 4, // 消耗品
  SPECIAL = 5, // 特殊物品
}

export enum CurrencyType {
  GOLD = 1, // 金币
  SILVER = 2, // 银币
  POINTS = 3, // 积分
}

@Entity("shop_goods")
@ManualTimestamp()
export class ShopGoodsEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column("int", { comment: "商品ID" })
  goodsId!: number;

  @Column("varchar", { length: 100, comment: "商品名称" })
  name!: string;

  @Column("text", { comment: "商品描述" })
  description!: string;

  @Column("varchar", { length: 128, comment: "商品图片" })
  picture!: string;

  @Column("int", {
    comment: "商品类型：1-药品，2-装备，3-材料，4-消耗品，5-特殊物品" })
  goodsType!: GoodsType;

  @Column("int", { comment: "货币类型：1-金币，2-银币，3-积分" })
  currencyType!: CurrencyType;

  @Column("int", { comment: "商品价格" })
  price!: number;

  @Column("int", { comment: "商品等级要求", default: 0 })
  levelRequirement!: number;

  @Column("int", { comment: "商品状态：0-下架，1-上架", default: 1 })
  status!: number;

  @Column("int", { comment: "每日购买限制", default: 0 })
  dailyLimit!: number;

  @Column("int", { comment: "商品库存", default: -1 })
  stock!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;
@Column("datetime", { name: "updated_at", nullable: true, comment: "更新时间" })
  updated_at!: Date | null;
}
